﻿@{ int Rows = (int)ViewBag.PagList.AllCount / ViewBag.PagList.PageSize + (ViewBag.PagList.AllCount % ViewBag.PagList.PageSize == 0 ? 0 : 1); }
<div class="dataTables_paginate fg-buttonset ui-buttonset fg-buttonset-multi ui-buttonset-multi paging_full_numbers"
    id="DataTables_Table_0_paginate">
    @if (ViewBag.PagList.PageIndex > 1)
    {
        <a class="first ui-corner-tl ui-corner-bl fg-button ui-button ui-state-default "
            href="javascript:void(0);" onclick="Paging(1)">首页</a>
        <a class="previous fg-button ui-button ui-state-default"  href="javascript:void(0);" onclick="Paging(@ViewBag.PagList.PageIndex-1)">
            上一页</a>
    }
    else
    {
        <a class="first ui-corner-tl ui-corner-bl fg-button ui-button ui-state-default ui-state-disabled">
            首页</a>
        <a class="previous fg-button ui-button ui-state-default ui-state-disabled">上一页</a>
    }
    <span>
        @for (int i = ViewBag.PagList.PageIndex - 2; i <= ViewBag.PagList.PageIndex + 2; i++)
        {
            if (i <= 0 || i > Rows)
            {
                continue;
            }
            if (i == ViewBag.PagList.PageIndex)
            {            
            <a class="fg-button ui-button ui-state-default ui-state-disabled">@i</a>
            }
            else
            {
            <a class="fg-button ui-button ui-state-default" onclick="Paging(@i)">@i</a>            
            }
        }
    </span>
    @if (Rows > ViewBag.PagList.PageIndex)
    { 
        <a tabindex="0" class="next fg-button ui-button ui-state-default"  href="javascript:void(0);" onclick="Paging(@ViewBag.PagList.PageIndex+1)">
            下一页</a>
        <a tabindex="0" class="last ui-corner-tr ui-corner-br fg-button ui-button ui-state-default"  href="javascript:void(0);" onclick="Paging(@Rows)">
            尾页</a>
    }
    else
    {
        <a tabindex="0" class="next fg-button ui-button ui-state-default ui-state-disabled">
            下一页</a>
        <a tabindex="0" class="last ui-corner-tr ui-corner-br fg-button ui-button ui-state-default ui-state-disabled">
            尾页</a>
    }
    <input id="PageIndex" name="PageIndex" type="hidden" value="@ViewBag.PagList.PageIndex" />
</div>
